import {
	onMounted,
	ref
} from "vue"
import {
	todayDataSummaryAPI,
	todayFactualAnalysisAPI
} from '@/api/dataScreenBig';

// 今日数据统计
export async function getTodayDataSummary() {
	const todaySummaryData = ref([])
	const todaySummaryDataConfig = [{
			name: '今日过境',
			num: 0,
			numKey: 'smTotal',
			unit: '人'
		},
		{
			name: '售票',
			num: 0,
			numKey: 'ticketSales',
			unit: '张'
		},
		{
			name: '过闸机',
			num: 0,
			numKey: 'ticketCheck',
			unit: '人'
		},
		{
			name: '来山车辆',
			num: 0,
			numKey: 'carAccTotal',
			unit: '辆'
		},
		{
			name: '客运进',
			num: 0,
			numKey: 'passInTotal',
			unit: '人'
		},
		{
			name: '客运出',
			num: 0,
			numKey: 'passOutTotal',
			unit: '人'
		},
		{
			name: '累计驻留',
			num: 0,
			numKey: 'stayTotal',
			unit: '人'
		},
	]

	const getTodayDataSummaryFunc = async () => {
		const res = await todayDataSummaryAPI()

		if (res.code !== 200) return
		todaySummaryData.value = todaySummaryDataConfig.map(item => Object.assign(item, {
			num: res.data[item.numKey]
		}))

		console.log('获取的 todaySummary 数据', todaySummaryData.value)
	}

	onMounted(() => {
		getTodayDataSummaryFunc()
	})

	return {
		todaySummaryData
	}
}